<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Letta服务器审计报告</title>
    <style>
        body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 20px; background-color: #f5f7fa; }
        .container { max-width: 1200px; margin: 0 auto; background: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; border-radius: 8px 8px 0 0; text-align: center; }
        .header h1 { margin: 0; font-size: 2.5em; }
        .header p { margin: 10px 0 0 0; opacity: 0.9; }
        .content { padding: 30px; }
        .section { margin-bottom: 40px; }
        .section h2 { color: #2c3e50; border-bottom: 3px solid #3498db; padding-bottom: 10px; margin-bottom: 20px; }
        .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
        .stat-card { background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #3498db; }
        .stat-card.high-risk { border-left-color: #e74c3c; }
        .stat-card.medium-risk { border-left-color: #f39c12; }
        .stat-card.low-risk { border-left-color: #27ae60; }
        .stat-value { font-size: 2em; font-weight: bold; color: #2c3e50; margin: 0; }
        .stat-label { color: #7f8c8d; margin: 5px 0 0 0; }
        .table { width: 100%; border-collapse: collapse; margin-top: 20px; }
        .table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
        .table th { background-color: #f1f3f4; font-weight: 600; }
        .table tr:hover { background-color: #f8f9fa; }
        .risk-high { color: #e74c3c; font-weight: bold; }
        .risk-medium { color: #f39c12; font-weight: bold; }
        .risk-low { color: #27ae60; }
        .alert { padding: 15px; margin: 15px 0; border-radius: 5px; }
        .alert-danger { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
        .alert-warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
        .alert-info { background-color: #d1ecf1; color: #0c5460; border: 1px solid #b8daff; }
        .financial-section { background: #fff8dc; border: 2px solid #daa520; border-radius: 8px; padding: 20px; margin: 20px 0; }
        .compliance-violation { background: #ffe6e6; border-left: 4px solid #ff4444; padding: 15px; margin: 10px 0; border-radius: 4px; }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🔍 Letta服务器审计报告</h1>
            <p>金融文档RAG系统安全审计与合规监控</p>
            <p>报告期间: 最近1小时 | 生成时间: 2025-08-26T15:59:19</p>
        </div>
        
        <div class="content">
            <!-- 概览统计 -->
            <div class="section">
                <h2>📊 概览统计</h2>
                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-value">39</div>
                        <div class="stat-label">总事件数</div>
                    </div>
                    <div class="stat-card high-risk">
                        <div class="stat-value">7</div>
                        <div class="stat-label">高风险事件</div>
                    </div>
                    <div class="stat-card medium-risk">
                        <div class="stat-value">2</div>
                        <div class="stat-label">中风险事件</div>
                    </div>
                    <div class="stat-card low-risk">
                        <div class="stat-value">30</div>
                        <div class="stat-label">低风险事件</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">6</div>
                        <div class="stat-label">失败事件</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">35.6</div>
                        <div class="stat-label">平均风险分数</div>
                    </div>
                </div>
                <div class="alert alert-danger">
                    <strong>⚠️ 安全警告:</strong> 检测到 7 个高风险事件，需要立即关注！
                </div>
            </div>
            
            <!-- 事件类型分布 -->
            <div class="section">
                <h2>📈 事件类型分布</h2>
                <table class="table">
                    <thead>
                        <tr>
                            <th>事件类型</th>
                            <th>数量</th>
                            <th>平均风险分数</th>
                            <th>风险评级</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>COMPLIANCE_CHECK</td>
                            <td>12</td>
                            <td>35.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                        <tr>
                            <td>FINANCIAL_DATA_ACCESS</td>
                            <td>5</td>
                            <td>91.0</td>
                            <td class="risk-high">高风险</td>
                        </tr>
                        <tr>
                            <td>USER_SESSION_START</td>
                            <td>5</td>
                            <td>10.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                        <tr>
                            <td>DOCUMENT_PROCESSING</td>
                            <td>4</td>
                            <td>15.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                        <tr>
                            <td>RAG_SEARCH</td>
                            <td>3</td>
                            <td>15.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                        <tr>
                            <td>AGENT_CREATION</td>
                            <td>2</td>
                            <td>15.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                        <tr>
                            <td>AGENT_MESSAGE</td>
                            <td>2</td>
                            <td>15.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                        <tr>
                            <td>DOCUMENT_ACCESS</td>
                            <td>2</td>
                            <td>50.0</td>
                            <td class="risk-medium">中风险</td>
                        </tr>
                        <tr>
                            <td>SYSTEM_ERROR</td>
                            <td>2</td>
                            <td>85.0</td>
                            <td class="risk-high">高风险</td>
                        </tr>
                        <tr>
                            <td>USER_SESSION_END</td>
                            <td>2</td>
                            <td>15.0</td>
                            <td class="risk-low">低风险</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!-- 金融活动分析 -->
            <div class="section financial-section">
                <h2>💰 金融活动分析</h2>
                
                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-value">4</div>
                        <div class="stat-label">总查询数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">1</div>
                        <div class="stat-label">金融相关查询</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">1</div>
                        <div class="stat-label">敏感查询</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">450.0ms</div>
                        <div class="stat-label">平均响应时间</div>
                    </div>
                </div>
                
                <h3>📋 理财产品查询统计</h3>
                <table class="table">
                    <thead>
                        <tr><th>查询类型</th><th>次数</th><th>平均风险分数</th></tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>financial_product_query</td>
                            <td>3</td>
                            <td class="risk-high">85.0</td>
                        </tr>
                        <tr>
                            <td>query_product_details</td>
                            <td>1</td>
                            <td class="risk-medium">65.0</td>
                        </tr>
                        <tr>
                            <td>query_investment_returns</td>
                            <td>1</td>
                            <td class="risk-high">70.0</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!-- 用户活动统计 -->
            <div class="section">
                <h2>👥 用户活动统计</h2>
                <table class="table">
                    <thead>
                        <tr>
                            <th>用户ID</th>
                            <th>事件数</th>
                            <th>平均风险</th>
                            <th>高风险事件</th>
                            <th>会话数</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>test_user_001</td>
                            <td>18</td>
                            <td class="risk-medium">43.1</td>
                            <td>7</td>
                            <td>1</td>
                        </tr>
                        <tr>
                            <td>test_analyzer</td>
                            <td>10</td>
                            <td class="risk-low">35.0</td>
                            <td>0</td>
                            <td>0</td>
                        </tr>
                        <tr>
                            <td>api_user_001</td>
                            <td>4</td>
                            <td class="risk-low">15.0</td>
                            <td>0</td>
                            <td>1</td>
                        </tr>
                        <tr>
                            <td>admin_user</td>
                            <td>2</td>
                            <td class="risk-low">35.0</td>
                            <td>0</td>
                            <td>1</td>
                        </tr>
                        <tr>
                            <td>api_user_002</td>
                            <td>2</td>
                            <td class="risk-medium">50.0</td>
                            <td>0</td>
                            <td>1</td>
                        </tr>
                        <tr>
                            <td>demo_user</td>
                            <td>2</td>
                            <td class="risk-low">12.5</td>
                            <td>0</td>
                            <td>1</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!-- 高风险事件详情 -->
            <div class="section">
                <h2>🚨 高风险事件详情</h2>
                <div class="alert alert-danger">
                    <strong>FINANCIAL_DATA_ACCESS</strong> (风险分数: 100)
                    <br>时间: 2025-08-26T15:55:20.671895
                    <br>用户: test_user_001
                    <br>操作: sensitive_data_query<br>错误: 未授权访问敏感数据</div>
                <div class="alert alert-danger">
                    <strong>FINANCIAL_DATA_ACCESS</strong> (风险分数: 100)
                    <br>时间: 2025-08-26T15:54:49.220933
                    <br>用户: test_user_001
                    <br>操作: sensitive_data_query<br>错误: 未授权访问敏感数据</div>
                <div class="alert alert-danger">
                    <strong>SYSTEM_ERROR</strong> (风险分数: 85)
                    <br>时间: 2025-08-26T15:55:20.671935
                    <br>用户: test_user_001
                    <br>操作: embedding_service_error<br>错误: BGE-M3嵌入服务连接超时</div>
                <div class="alert alert-danger">
                    <strong>FINANCIAL_DATA_ACCESS</strong> (风险分数: 85)
                    <br>时间: 2025-08-26T15:55:20.671742
                    <br>用户: test_user_001
                    <br>操作: financial_product_query</div>
                <div class="alert alert-danger">
                    <strong>SYSTEM_ERROR</strong> (风险分数: 85)
                    <br>时间: 2025-08-26T15:54:49.220977
                    <br>用户: test_user_001
                    <br>操作: embedding_service_error<br>错误: BGE-M3嵌入服务连接超时</div>
                <div class="alert alert-danger">
                    <strong>FINANCIAL_DATA_ACCESS</strong> (风险分数: 85)
                    <br>时间: 2025-08-26T15:54:49.220816
                    <br>用户: test_user_001
                    <br>操作: financial_product_query</div>
                <div class="alert alert-danger">
                    <strong>FINANCIAL_DATA_ACCESS</strong> (风险分数: 85)
                    <br>时间: 2025-08-26T15:53:48.798482
                    <br>用户: test_user_001
                    <br>操作: financial_product_query</div></div>
            <!-- 合规违规事件 -->
            <div class="section">
                <h2>⚖️ 合规违规事件</h2>
                <div class="compliance-violation">
                    <strong>PRODUCT_INFO_QUERY</strong>
                    <br>时间: 2025-08-26T15:59:19.911265
                    <br>用户: demo_user
                    <br>违规项: missing_risk_disclosure, missing_product_description, missing_fee_structure, missing_redemption_terms<br>金融类别: product_info,risk_terms</div>
                <div class="compliance-violation">
                    <strong>FINANCIAL_DATA_ACCESS</strong>
                    <br>时间: 2025-08-26T15:55:20.671895
                    <br>用户: test_user_001
                    <br>违规项: missing_risk_disclosure, missing_product_description, missing_fee_structure, missing_redemption_terms<br>金融类别: sensitive_data</div>
                <div class="compliance-violation">
                    <strong>FINANCIAL_DATA_ACCESS</strong>
                    <br>时间: 2025-08-26T15:55:20.671742
                    <br>用户: test_user_001
                    <br>违规项: missing_risk_disclosure, missing_product_description, missing_fee_structure, missing_redemption_terms<br>金融类别: product_info,risk_terms,amount_terms</div>
                <div class="compliance-violation">
                    <strong>FINANCIAL_DATA_ACCESS</strong>
                    <br>时间: 2025-08-26T15:54:49.220933
                    <br>用户: test_user_001
                    <br>违规项: missing_risk_disclosure, missing_product_description, missing_fee_structure, missing_redemption_terms<br>金融类别: sensitive_data</div>
                <div class="compliance-violation">
                    <strong>FINANCIAL_DATA_ACCESS</strong>
                    <br>时间: 2025-08-26T15:54:49.220816
                    <br>用户: test_user_001
                    <br>违规项: missing_risk_disclosure, missing_product_description, missing_fee_structure, missing_redemption_terms<br>金融类别: product_info,risk_terms,amount_terms</div>
                <div class="compliance-violation">
                    <strong>FINANCIAL_DATA_ACCESS</strong>
                    <br>时间: 2025-08-26T15:53:48.798482
                    <br>用户: test_user_001
                    <br>违规项: missing_risk_disclosure, missing_product_description, missing_fee_structure, missing_redemption_terms<br>金融类别: product_info,risk_terms,amount_terms</div></div>
            <!-- 系统健康状态 -->
            <div class="section">
                <h2>🏥 系统健康状态</h2>
                <div class="alert alert-danger">
                    🚨 系统存在较多高风险事件，需要立即处理
                </div>
                
                <h3>📊 风险分布</h3>
                <div>
                    <div>高风险事件: 7 (17.9%)</div>
                    <div>中风险事件: 2 (5.1%)</div>
                    <div>低风险事件: 30 (76.9%)</div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>